<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机选人系统</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            margin: 0;
            padding: 0;
            background-image: url('background.jpg');
            background-size: cover;
            background-position: center;
            background-attachment: fixed;
            color: #fff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        
        .container {
            background-color: rgba(0, 0, 0, 0.7);
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
            width: 90%;
            max-width: 1000px;
            text-align: center;
            position: relative;
            min-height: 400px;
            display: flex;
            flex-direction: column;
        }
        
        h1 {
            margin-top: 0;
            margin-bottom: 40px;
            font-size: 2.5rem;
            color: #fff;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
        }
        
        .main-content {
            display: flex;
            flex: 1;
            justify-content: space-between;
            align-items: stretch;
        }
        
        .settings {
            flex: 0 0 300px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            text-align: left;
            margin-right: 20px;
        }
        
        .center-section {
            flex: 0 0 200px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        
        .result-section {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            margin-left: 20px;
            text-align: left;
        }
        
        .input-group {
            margin-bottom: 20px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            font-size: 1.1rem;
        }
        
        input {
            padding: 10px;
            border-radius: 5px;
            border: none;
            width: 100%;
            background-color: rgba(255, 255, 255, 0.9);
            font-size: 1rem;
        }
        
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 15px 30px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 1.2rem;
            margin: 10px 5px;
            cursor: pointer;
            border-radius: 50px;
            transition: all 0.3s;
            width: 160px;
        }
        
        button:hover {
            background-color: #45a049;
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        }
        
        .result {
            font-size: 2.5rem;
            line-height: 1.5;
            opacity: 1;
            text-align: center;
        }
        
        .result-number {
            display: inline-block;
            font-size: 4rem;
            font-weight: bold;
            color: #4CAF50;
            text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
            animation: numberPop 0.5s ease-out;
        }
        
        .result-text {
            display: inline-block;
            margin: 0 10px;
        }
        
        @keyframes numberPop {
            0% {
                transform: scale(0.3);
                opacity: 0;
            }
            50% {
                transform: scale(1.2);
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }
        
        .drum-roll {
            font-size: 3rem;
            color: #fff;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
            animation: drumRoll 0.3s linear infinite;
        }
        
        @keyframes drumRoll {
            0% { transform: scale(1); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
        
        #selectBtn:disabled {
            background-color: #cccccc;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        
        .hide {
            display: none;
        }
        
        .result-item {
            background-color: rgba(76, 175, 80, 0.2);
            padding: 10px 15px;
            border-radius: 5px;
            margin-bottom: 10px;
            border-left: 4px solid #4CAF50;
            animation: slideIn 0.5s ease-out;
        }
        
        @keyframes slideIn {
            from {
                transform: translateX(-20px);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
        
        .section-title {
            font-size: 1.3rem;
            margin-bottom: 20px;
            color: #4CAF50;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>随机选人系统</h1>
        
        <div class="main-content">
            <div class="settings">
                <div class="section-title">配置信息</div>
                <div class="input-group">
                    <label for="rows">座位排数:</label>
                    <input type="number" id="rows" min="1" value="6">
                </div>
                
                <div class="input-group">
                    <label for="cols">座位列数:</label>
                    <input type="number" id="cols" min="1" value="8">
                </div>
            </div>
            
            <div class="center-section">
                <button id="selectBtn">开始抽取</button>
                <button id="resetBtn">重置</button>
            </div>
            
            <div class="result-section">
                <div class="section-title">抽取结果</div>
                <div class="result" id="result"></div>
            </div>
        </div>
    </div>
    
    <script>
        let seats = [];
        let selectedSeats = [];
        
        // 初始化座位
        function initializeSeats() {
            const rows = parseInt(document.getElementById('rows').value);
            const cols = parseInt(document.getElementById('cols').value);
            
            if (isNaN(rows) || rows < 1 || isNaN(cols) || cols < 1) {
                alert('请输入有效的排数和列数！');
                return false;
            }
            
            seats = [];
            for (let i = 1; i <= rows; i++) {
                for (let j = 1; j <= cols; j++) {
                    seats.push({ row: i, col: j });
                }
            }
            return true;
        }
        
        function selectRandomSeats() {
            if (!initializeSeats()) return;
            
            const selectBtn = document.getElementById('selectBtn');
            selectBtn.disabled = true;
            
            const availableSeats = seats.filter(seat => 
                !selectedSeats.some(selected => 
                    selected.row === seat.row && selected.col === seat.col
                )
            );
            
            if (availableSeats.length === 0) {
                alert('所有座位都已被选择！');
                selectBtn.disabled = false;
                return;
            }
            
            const randomIndex = Math.floor(Math.random() * availableSeats.length);
            const selectedSeat = availableSeats[randomIndex];
            selectedSeats.push(selectedSeat);
            
            displayResultWithAnimation(selectedSeat);
        }
        
        function displayResultWithAnimation(seat) {
            const resultElement = document.getElementById('result');
            resultElement.innerHTML = '<div class="drum-roll">?</div>';
            
            // 先显示行数
            setTimeout(() => {
                resultElement.innerHTML = `
                    <div>
                        <span class="result-text">第</span>
                        <span class="result-number">${seat.row}</span>
                        <span class="result-text">排</span>
                    </div>
                `;
                
                // 再显示列数
                setTimeout(() => {
                    resultElement.innerHTML += `
                        <div>
                            <span class="result-text">第</span>
                            <span class="result-number">${seat.col}</span>
                            <span class="result-text">列</span>
                        </div>
                    `;
                    
                    // 启用按钮
                    document.getElementById('selectBtn').disabled = false;
                }, 1000);
            }, 1000);
        }
        
        function reset() {
            document.getElementById('rows').value = 6;
            document.getElementById('cols').value = 8;
            seats = [];
            selectedSeats = [];
            const resultElement = document.getElementById('result');
            resultElement.innerHTML = '';
            document.getElementById('selectBtn').disabled = false;
        }
        
        document.getElementById('selectBtn').addEventListener('click', selectRandomSeats);
        document.getElementById('resetBtn').addEventListener('click', reset);
    </script>
</body>
</html> 